package com.acegear.horizon.domain.models.jpa;

import com.fasterxml.jackson.annotation.JsonIgnore;

import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

/**
 * Created by mercury on 2016/12/18.
 */
@Entity
@EntityListeners(AuditingEntityListener.class)
public class Address {

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@JsonIgnore
	private Long id;

	@Column
	private String country;

	@Column
	private String province;

	@Column
	private String city;

	@Column
	private String district;

	@Column
	private String address;

	@CreatedDate
	@Column
	private Long createAt;

	@LastModifiedDate
	@Column
	private Long updateAt;

	public Address() {

	}

	public Address(String country, String province, String city, String district, String address) {
		this.country = country;
		this.province = province;
		this.city = city;
		this.district = district;
		this.address = address;
	}

	public Long getCreateAt() {
		return createAt;
	}

	public Long getUpdateAt() {
		return updateAt;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getCountry() {
		return country;
	}

	public void setCountry(String country) {
		this.country = country;
	}

	public String getProvince() {
		return province;
	}

	public void setProvince(String province) {
		this.province = province;
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public String getDistrict() {
		return district;
	}

	public void setDistrict(String district) {
		this.district = district;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public void setCreateAt(Long createAt) {
		this.createAt = createAt;
	}

	public void setUpdateAt(Long updateAt) {
		this.updateAt = updateAt;
	}

	public void update(Address other) {
		this.address = other.getAddress();
		this.city = other.getCity();
		this.country = other.getCountry();
		this.district = other.getDistrict();
		this.province = other.getProvince();
	}
}
